//
//  GYMarketCenterListVC.m
//  GYDemo
//
//  Created by Mrzhang on 2018/4/2.
//  Copyright © 2018年 mac. All rights reserved.
//

//
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                  \\`.
//        .'//                     |                     \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
//    .'//.-"                 `-.  |  .-'                 "-.\\`.
//  .'//______.============-..   \ | /   ..-============.______\\`.
//.'______________________________\|/______________________________`.
//
//

#import "GYMarketCenterListVC.h"
#import "Head.h"
#import "GYMarksetCenterListViewModel.h"
#import "NNNoticeListCell.h"
@interface GYMarketCenterListVC ()
{
    NSInteger page;
}
@property(nonatomic,strong)GYMarksetCenterListViewModel* listViewModel;
@end

@implementation GYMarketCenterListVC
#pragma mark - getter and setter
-(GYMarksetCenterListViewModel *)listViewMode
{
    if (!_listViewModel) {
        _listViewModel=[[GYMarksetCenterListViewModel alloc] init];
    }
    return _listViewModel;
}
#pragma mark - event
#pragma mark - method
-(void)viewModelBand
{
    @WeakSelf;
    GCBaseObservationModel* saleOber=[GCBaseObservationModel new];
    saleOber.keyPath=@"datas";
    saleOber.observation=self.listViewModel;
    saleOber.handler = ^(NSString *keyPath) {
        [selfp.baseTable reloadData];
    };
    [self registObservation:saleOber];
}
-(void)loadData
{

    NSMutableDictionary* para=[[NSMutableDictionary alloc] init];

    [self.listViewModel doRequsetData:para];
}
#pragma mark - life
#pragma mark - life
- (void)viewDidLoad {
    [super viewDidLoad];
    if (!_listViewModel) {
        _listViewModel=[[GYMarksetCenterListViewModel alloc] init];
    }
    page=1;
    self.title=@"行情中心";
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = [UIColor whiteColor];


    self.baseTable.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
    self.baseTable.backgroundColor=[UIColor whiteColor];
    self.baseTable.height=self.baseTable.height-GY_Nav_height-self.bottomShelterHeight;
    [self.view addSubview:self.baseTable];
    [self.baseTable registerNib:[UINib nibWithNibName:@"NNNoticeListCell" bundle:nil] forCellReuseIdentifier:@"NNNoticeListCell"];

    
    @WeakSelf;
    self.baseTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        page = 1;
        [selfp loadData];
    }];


    [self viewModelBand];
    [self loadData];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.listViewModel.datas.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    return 100;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellIdentifier = @"NNNoticeListCell";
    NNNoticeListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    GYHomeMarketInfoModel* model=self.listViewModel.datas[indexPath.row];
    [cell.coverIV sd_setImageWithURL:[NSURL URLWithString:model.cover]];
    cell.titleLab.text=model.title;
    cell.timeLab.text=model.time;
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    GYHomeMarketInfoModel* model=self.listViewModel.datas[indexPath.row];
    GCBaseWebVC* gy=[[GCBaseWebVC alloc] init];
    gy.information=@{@"url":model.url,@"title":model.title};
    [self.navigationController pushViewController:gy animated:YES];
}
@end


/*
 11111111111111111111111111111111111111001111111111111111111111111
 11111111111111111111111111111111111100011111111111111111111111111
 11111111111111111111111111111111100001111111111111111111111111111
 11111111111111111111111111111110000111111111111111111111111111111
 11111111111111111111111111111000000111111111111111111111111111111
 11111111111111111111111111100000011110001100000000000000011111111
 11111111111111111100000000000000000000000000000000011111111111111
 11111111111111110111000000000000000000000000000011111111111111111
 11111111111111111111111000000000000000000000000000000000111111111
 11111111111111111110000000000000000000000000000000111111111111111
 11111111111111111100011100000000000000000000000000000111111111111
 11111111111111100000110000000000011000000000000000000011111111111
 11111111111111000000000000000100111100000000000001100000111111111
 11111111110000000000000000001110111110000000000000111000011111111
 11111111000000000000000000011111111100000000000000011110001111111
 11111110000000011111111111111111111100000000000000001111100111111
 11111111000001111111111111111111110000000000000000001111111111111
 11111111110111111111111111111100000000000000000000000111111111111
 11111111111111110000000000000000000000000000000000000111111111111
 11111111111111111100000000000000000000000000001100000111111111111
 11111111111111000000000000000000000000000000111100000111111111111
 11111111111000000000000000000000000000000001111110000111111111111
 11111111100000000000000000000000000000001111111110000111111111111
 11111110000000000000000000000000000000111111111110000111111111111
 11111100000000000000000001110000001111111111111110001111111111111
 11111000000000000000011111111111111111111111111110011111111111111
 11110000000000000001111111111111111100111111111111111111111111111
 11100000000000000011111111111111111111100001111111111111111111111
 11100000000001000111111111111111111111111000001111111111111111111
 11000000000001100111111111111111111111111110000000111111111111111
 11000000000000111011111111111100011111000011100000001111111111111
 11000000000000011111111111111111000111110000000000000011111111111
 11000000000000000011111111111111000000000000000000000000111111111
 11001000000000000000001111111110000000000000000000000000001111111
 11100110000000000001111111110000000000000000111000000000000111111
 11110110000000000000000000000000000000000111111111110000000011111
 11111110000000000000000000000000000000001111111111111100000001111
 11111110000010000000000000000001100000000111011111111110000001111
 11111111000111110000000000000111110000000000111111111110110000111
 11111110001111111100010000000001111100000111111111111111110000111
 11111110001111111111111110000000111111100000000111111111111000111
 11111111001111111111111111111000000111111111111111111111111100011
 11111111101111111111111111111110000111111111111111111111111001111
 11111111111111111111111111111110001111111111111111111111100111111
 11111111111111111111111111111111001111111111111111111111001111111
 11111111111111111111111111111111100111111111111111111111111111111
 11111111111111111111111111111111110111111111111111111111111111111
 
 
 */
